<template>
<div>
  <el-row :span="4" style="margin-bottom: 30px"><el-icon><document-add /></el-icon> 添加调度命令</el-row>
  <el-row>
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="主题:">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="类型:">
        <el-select v-model="value" placeholder="请选择">
          <el-option
            v-for="item in list"
            :key="item.id"
            :label="item.value"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="发布人:">
        <el-input placeholder="发布人" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="接受人:">
        <el-checkbox-group v-model="form.type">
          <el-checkbox v-for="item in list2" :key="item.id" :label="item.value" :value="item.id" name="type"></el-checkbox>
        </el-checkbox-group>
        <el-checkbox label="全选" name="type" @change="allSelected()"></el-checkbox>
      </el-form-item>
      <el-form-item label="编号:">
        <el-input v-model="form.no"></el-input>
      </el-form-item>
      <el-form-item label="附件:">
        <el-upload
          ref="upload"
          class="upload-demo"
          action="https://jsonplaceholder.typicode.com/posts/"
          :auto-upload="false"
        >
          <template #trigger>
            <el-button size="small" type="primary">select file</el-button>
          </template>
        </el-upload>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
        <el-button>重置</el-button>
      </el-form-item>
    </el-form>
  </el-row>
</div>
</template>

<script>
export default {
  name: "MyRelease",
  data() {
    return {
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: '',

      },
      value:'',
      list:[{
          id:0,
          value:"客调命令"
        },
        {
          id:1,
          value:"运行揭示"
        },
        {
          id:2,
          value:"施工命令"
        },
        {
          id:3,
          value:"设备故障"
        },
        {
          id:4,
          value:"段调度命令"
        },
        {
          id:5,
          value:"检修计划"
        },
        {
          id:6,
          value:"作业申请"
        },
        {
          id:7,
          value:"进入签收"
        }],
      list2:[{
          id:0,
          value:"段办"
        },
        {
          id:1,
          value:"劳人科"
        },
        {
          id:2,
          value:"财务科"
        },
        {
          id:3,
          value:"材料科"
        },
        {
          id:4,
          value:"其他"
        }],

    }
  },
  methods: {
    onSubmit() {
      console.log('submit!')
    },
    allSelected(){
      if(this.form.type.length!=5)
      this.form.type = ["段办","劳人科","财务科","材料科","其他"];
      else this.form.type = [];
    }
  },
}
</script>

<style scoped>

</style>
